package com.eveinfo.display.skills;

import java.util.Collection;
import java.util.HashMap;

import com.eveinfo.api.character.sheet.ApiKnownSkill;
import com.eveinfo.api.utils.skilllist.ApiRequirement;
import com.eveinfo.api.utils.skilllist.ApiSkill;

public class TrainableSkillsFilter implements SkillsFilter {

	
	private HashMap<Integer, ApiKnownSkill> skills;
	
	public TrainableSkillsFilter(HashMap<Integer, ApiKnownSkill> set) {
		this.skills = set;
		if (set == null)
			return;
	}

	@Override
	public boolean isDisplay(ApiSkill skill) {
		
		if(skills.containsKey(skill.getTypeID()))
			return false;
		
		Collection<ApiRequirement> requiredSkills = skill.getRequiredSkills();
		for(ApiRequirement requirement : requiredSkills){
			ApiKnownSkill skillReq = skills.get(requirement.getTypeID());
			if(skillReq == null || skillReq.getLevel() < requirement.getSkillLevel())
				return false;
		}
		return true;
	}
}
